#ifndef _WDDM_INCLUDE_VBOXMPMEM_H_
#define _WDDM_INCLUDE_VBOXMPMEM_H_

#include "CommonDef.h"

#define RTMEMHDR_MAGIC 0x18090119
#define RTR0MEM_FENCE_EXTRA 0

typedef struct RTMEMHDR
{
    /** Magic (RTMEMHDR_MAGIC). */
    UINT32    u32Magic;
    /** Block flags (RTMEMHDR_FLAG_*). */
    UINT32    fFlags;
    /** The actual size of the block, header not included. */
    UINT32    cb;
    /** The requested allocation size. */
    UINT32    cbReq;
} RTMEMHDR, * PRTMEMHDR;

void* RTMemAlloc(size_t cb);
void RTMemFree(void* pv);
void* RTMemRealloc(void* pvOld, size_t cbNew);

#define RTMEM_ALIGNMENT 8

/** No access at all. */
#define RTMEM_PROT_NONE   0
/** Read access. */
#define RTMEM_PROT_READ   1
/** Write access. */
#define RTMEM_PROT_WRITE  2
/** Execute access. */
#define RTMEM_PROT_EXEC   4

DECLINLINE(void*) RTMemAllocZTag(size_t cb, const char* pszTag)
{
    (void)pszTag;
    void* pTmp = RTMemAlloc(cb);
    if (pTmp) {
        memset(pTmp, 0, cb);
    }
    return pTmp;
}

#define RTMemAllocZ(cb) RTMemAllocZTag((cb), __FILE__)

#endif
